<template>
	<view class="main">
		<view class="items">
			<view class="item" @click="gotoDetail(item)" v-for="item in datas">
				<view class="top">
					<view class="date">{{item.see_time}}</view>
					<view class="status" v-if="item.status == 0">待支付</view>
					<view class="status" v-else-if="item.status == 1">待就诊</view>
					<view class="status" v-else-if="item.status == 2">就诊中</view>
					<view class="status" v-else-if="item.status == 3">已看诊</view>
					<view class="status" v-else-if="item.status == 4">已过号</view>
					<view class="status" v-else-if="item.status == 5">已取消</view>
				</view>
				<view class="bottom">
					<view class="left">
						<image class="cover" src="../../static/images/f.png"></image>
					</view>
					<view class="center">
						<view class="up">
							<view class="name">{{item.user_name}}</view>
						</view>
						<view class="it">
							就诊事项：{{item.sub_item_name}}
						</view>
						<view class="it">
							医生：{{item.doc_name}}
						</view>
					</view>
					<view class="right">
						{{item.no}}号
					</view>
				</view>
			</view>
		</view><!--items end-->
	</view>
</template>

<script>
	import {getCheckedList} from '@/api/check.js'
	export default {
		data() {
			return {
				page:1,
				limit:10,
				status:false,
				datas:[]
			}
		},
		onLoad() {
			this.getDataList();
		},
		onPullDownRefresh() {
			this.page = 1;
			this.getDataList();
		},
		onReachBottom: function() {
			this.getDataList();
		},
		methods: {
			gotoDetail(item){
				uni.navigateTo({
					url:'/pages/records/detail?id='+item.id
				})
			},
			getDataList() {
				let that = this;
				
				let limit = that.limit;
				let page = that.page;
				let dataList = that.datas;
				if (that.status) return;
				getCheckedList({
					page: page,
					limit: limit
				}).then(res => {
					let datasNew = [];
					let len = res.data.count;
					datasNew = dataList.concat(res.data.list);
					that.page++;
					that.$set(that, 'datas', datasNew);
					that.status = limit > len;
					that.page = that.page;
				});
			}
		}
	}
</script>

<style lang="scss">
	page {
	  width: 100%;
	  height: 100%;
	  // background-color: white;
	}
	.main {
		display: flex;
		flex-direction: column;
		padding: 30rpx;
		padding-bottom: 0;  
		padding-bottom: constant(safe-area-inset-bottom);  
		padding-bottom: env(safe-area-inset-bottom); 
		.items{
			display: flex;
			flex-direction: column;
			padding-bottom: 30rpx;
			.item{
				display: flex;
				flex-direction: column;
				background-color: #FFFFFF;
				// box-shadow: 0px 3px 6px 2px rgba(0, 0, 0, 0.1);
				border-radius: 10rpx;
				border-bottom: 1rpx solid #f1f1f1;
				margin-top: 20rpx;
				padding: 0rpx 30rpx 30rpx 30rpx;
				.top{
					display: flex;
					flex-direction: row;
					justify-content: space-between;
					align-items: center;
					height: 80rpx;
					border-bottom: 1rpx solid #f1f1f1;
					.date{
						font-size: 24rpx;
						color: black;
					}
					.status{
						font-size: 24rpx;
						color: darkred;
					}
				}
				.bottom{
					margin-top: 30rpx;
					display: flex;
					flex-direction: row;
					.left{
						display: flex;
						flex-direction: row;
						.cover{
							width: 120rpx;
							height: 120rpx;
							border-radius: 60rpx;
						}
					}
					.center{
						margin-left: 15rpx;
						display: flex;
						flex-direction: column;
						flex:1;
						.up{
							display: flex;
							flex-direction: row;
							align-items: center;
							.name{
								font-weight: bold;
								font-size: 30rpx;
								color: black;
							}
							.title{
								font-size: 22rpx;
								color: brown;
								margin-left: 5rpx;
							}
						}
						.it{
							font-size: 24rpx;
							color: gray;
							margin-top: 5rpx;
						}
						.tags{
							margin-top: 30rpx;
							display: flex;
							flex-direction: row;
							flex-wrap: wrap;
							.tag{
								padding: 10rpx 15rpx;
								border-radius: 10rpx;
								color: saddlebrown;
								background-color: oldlace;
								font-size: 22rpx;
								margin-right: 15rpx;
								margin-bottom: 15rpx;
							}
						}
					}
					.right{
						width: 80rpx;
						font-size: 28rpx;
						color: black;
						display: flex;
						flex-direction: row;
						align-items: center;
						justify-content: flex-end;
					}
				}
			}//item
		}//end items
	}
</style>
